//
//  CustomButton.swift
//  KeyboardAndEmoji
//
//  Created by momo on 2025/8/3.
//

import UIKit
import SnapKit
class CustomButton: UIButton {

    lazy var imgView: UIImageView = {
        let imageView = UIImageView()
        imageView.contentMode = .scaleToFill
//        imageView.image = KImage("")
        imageView.isUserInteractionEnabled = false
        return imageView
    }()
    
    
    var normalImage : UIImage? {
        didSet {
            imgView.image = normalImage
        }
    }
    var selectImage : UIImage? {
        didSet {
            imgView.image = selectImage
        }
    }

    override init(frame: CGRect) {
        super.init(frame: frame)
        setUpdataUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setUpdataUI() {
        addSubview(imgView)
        imgView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
    }
    
    override var isSelected: Bool {
        didSet {
            imgView.image = isSelected ? selectImage : normalImage
        }
    }
}
